#! c:\\Perl\\bin\\perl.exe w

use strict;
use ADN::LIBRARY::IP::Ip;
use ADN::LIBRARY::SOAP::ClientSOAP;
use ADN::XML::OBJtoXML;

my $ip = $ARGV[0];
my $Srep = $ARGV[1];
my $param = $ARGV[2];

main();
exit 0;

sub main {

  my ( $rep, $xml, $nbr, $verifip );
  my ( @tab, @prm, @result );

  @tab = split /\%\!\%\*\%\~\%/smx, $param;
  $nbr = scalar @tab;
  print "NBR : $nbr\n";

  for ( my $i = 0; $i < $nbr; $i++ ) {
    @prm = split /\@\#\@\*\@\~\@/smx, $tab[$i];
  }

  $nbr = scalar @prm;
  print "NBR PRM : $nbr\n";

  if ($nbr != 2) {
    print 'Erreur ARG !!!';
    exit 0;
  }

  print "Arg: $prm[0]/$prm[1]\n\n";

  if (($verifip = ADN::LIBRARY::IP::Ip->new($prm[0].'/'.$prm[1])) =~ m/^0$/smx)
  {
    $rep = '0';
  }
  else
  {
    $rep = '1';
  }

  $xml = ADN::XML::OBJtoXML->new();
  $xml->Ip($prm[0]);
  $xml->Mask($prm[1]);
  $xml->Ip($xml);
  @result = $xml->Valide($rep);

  print 'DATA : ';
  print @result;

  ADN::LIBRARY::SOAP::ClientSOAP->new( Proxy => $ip,
						                           Service => $Srep,
						                           Data => \@result );

  return;
}